import 'package:example/page/check_smear_page.dart';
import 'package:example/page/blank_toolbar.dart';
import 'package:example/page/multi_threading.dart';
import 'package:example/page/music_player.dart';
import 'package:example/page/music_player_page.dart';
import 'package:example/page/read_write_page.dart';
import 'package:example/page/syncfusion_charts_page.dart';
import 'package:example/page/three_callBack.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'datebase/led_converter.dart';
import 'dart:ui';
import 'dart:ui' as ui;
import 'page/vibration.dart';
import 'page/pixels_viewPage.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        // This is the theme of your application.
        //
        // Try running your application with "flutter run". You'll see the
        // application has a blue toolbar. Then, without quitting the app, try
        // changing the primarySwatch below to Colors.green and then invoke
        // "hot reload" (press "r" in the console where you ran "flutter run",
        // or simply save your changes to "hot reload" in a Flutter IDE).
        // Notice that the counter didn't reset back to zero; the application
        // is not restarted.
        primarySwatch: Colors.blue,
      ),
      home: const MaterialApp(
        home: MyHomePage(),
        debugShowCheckedModeBanner: false,
      ),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key}) : super(key: key);

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  late ui.Picture picture;
  @override
  void initState() {
    // TODO: implement initState
    picture = LedConverter.convert(text: "果", canvasSize: Offset(12, 12),);
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.black,
      appBar: AppBar(
        backgroundColor: Colors.white38,
        title: const Text("CustomView"),
      ),
      body: Container(
        width: MediaQuery.of(context).size.width,
        height: MediaQuery.of(context).size.height,
        padding: const EdgeInsets.symmetric(vertical: 10),
        color: Colors.black54,
        child: SingleChildScrollView(
          scrollDirection: Axis.vertical,
          child: Column(
            children:  [
              ListTileItem(
                page: PixelsViewPage(),
                text: "像素显示",
              ),
              ListTileItem(
                page: const CheckSmearPage(),
                text: "方块涂抹",
              ),
              ListTileItem(
                page: BlankToolBar(),
                text: "键盘TooBar",
              ),
              ListTileItem(
                page: MusicaPlayer(),
                text: "音乐模式",
              ),
              ListTileItem(
                page: SyncfusionChartsPage(),
                text: "图表模式",
              ),
              ListTileItem(
                page: ReadAndWritePage(),
                text: "读写文件",
              ),
              ListTileItem(
                page: VibratingApp(),
                text: "震动反馈",
              ),
              ListTileItem(
                page: ThreeCallBack(),
                text: "回调",
              ),
              ListTileItem(
                page: MultiThreadPage(),
                text: "多线程",
              ),
              ListTileItem(
                page: MusicPlayerPage(),
                text: "多线程",
              ),
            ],
          ),
        ),
      ),
    );
  }
}


class ListTileItem extends StatelessWidget {
  final Widget page;
  final String text;

  ListTileItem({required this.page, required this.text});

  @override
  Widget build(BuildContext context) {
    return Container(
      color: Colors.white12,
      margin: const EdgeInsets.symmetric(vertical: 10),
      child: ListTile(
        onTap: () {
          Navigator.push(context, MaterialPageRoute(builder: (context) => page));
        },
        title: Text(text,style: const TextStyle(fontSize: 18,color: Colors.white),),
        trailing: const Icon(Icons.arrow_forward_ios_rounded),
      ),
    );
  }
}
